import axios from 'axios'
// 设置基准路径
const baseURL = 'http://127.0.0.1:3000'
axios.defaults.baseURL = baseURL
// 设置axios携带cokkie信息
axios.defaults.withCredentials = true
// 用户模块
// => 登录接口
export const loginUser = (options) => {
  return axios.post('/employee/employeeLogin', options).then(res => {
    return res.data
  })
}
// => 判断用户是否登录
export const isLogin = () => {
  return axios.get('/employee/checkRootLogin').then(res => {
    return res.data
  })
}
// => 登出接口
export const loginOut = () => {
  return axios.get('/employee/employeeLogout').then(res => {
    return res.data
  })
}
// => 获取所有用户数据(列表)
export const getUserList = (options) => {
  return axios.get('/user/queryUser', {params: options}).then(res => {
    return res.data
  })
}
// => 禁用用户
export const setDisUser = (options) => {
  return axios.post('/user/updateUser', options).then(res => {
    return res
  })
}
// 产品模块
// =>获取产品列表
export const getCategoryList = (options) => {
  return axios.get('/product/queryProductDetailList', {params: options}).then(res => {
    return res.data
  })
}
// 分类模块
// =>查询1级分类列表
export const getFristCategoryList = (options) => {
  return axios.get('/category/queryTopCategoryPaging', {params: options}).then(res => {
    return res.data
  })
}
// =>添加一级分类
export const addFristCategory = (options) => {
  return axios.post('/category/addTopCategory', options).then(res => {
    return res.data
  })
}
// =>编辑一级分类
export const editFristCategory = (options) => {
  return axios.post('/category/updateTopCategory', options).then(res => {
    return res.data
  })
}
// =>查询2级分类列表
export const getSecondCategoryList = (options) => {
  return axios.get('/category/querySecondCategoryPaging', {params: options}).then(res => {
    return res.data
  })
}
// =>添加2级分类
export const addSecondCategoryList = (options) => {
  return axios.post('/category/addSecondCategory', options).then(res => {
    return res.data
  })
}
// =>编辑二级分类
export const editSecondCategoryList = (options) => {
  return axios.post('/category/updateSecondCategory', options).then(res => {
    return res.data
  })
}
// 商品管理模块
// => 商品列表查询
export const getProductDetailList = (options) => {
  return axios.get('/product/queryProductDetailList', {params: options}).then(res => {
    return res.data
  })
}
